#include "StdAfx.h"
#include "MainDlg.h"
#include "WEGlobal.h"
#include "WceUiLayerCtrl.h"
#include "WceUiDlg.h"

CMainDlg::CMainDlg(void)
{
}

CMainDlg::~CMainDlg(void)
{
}

void CMainDlg::OnLButtonDown(UINT nFlags, POINT point)
{
	CRect rc(0, 0, 100, 100);
	if (rc.PtInRect(point))
	{
		EndDialog(0);
	}
}


LRESULT CMainDlg::OnCommand(UINT uCommand, WPARAM wParam, LPARAM lParam)
{
	if (CMD_WE_I_CLICK == uCommand)
	{
		OnCmd((CWceUiLayer*)wParam);
	}

	return 0;
}

void CMainDlg::OnCmd(CWceUiLayer* pLayer)
{
	if (pLayer->IsEqualName(L"settings"))
	{
		CWceUiDlg* pDlg = GetLayerCtrl()->CreateDlg(L"CSettingsDlg");
		ASSERT(NULL != pDlg);
		pDlg->DoModal();
		GetLayerCtrl()->DeleteLayer(pDlg);
		pDlg = NULL;
	}else if(pLayer->IsEqualName(L"photos"))
	{
		TCHAR szPath[MAX_PATH] = {0};
		WEGetExePath(szPath);
		_tcscat(szPath, L"AppPhoto.exe");
		WEWinExec(szPath);
	}
}

void CMainDlg::OnInitDialog()
{
	m_pFrame = (CWEILayer*)GetChildByName(L"bottom_frame");
	ASSERT(NULL != m_pFrame);
	ASSERT(m_pFrame->IsKindOf(WCEUI_CLASS_NAME(CWEILayer)));
	m_pFrame->SetSlideSpeed(1, 1, 1);
	m_pFrame->SetBlockSlide(TRUE);
}
